home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / rwvector.lha / RWVector2.1 / rw / DComplexFFT.h < prev    next >
C/C++ Source or Header  |  1989-08-18  |  2KB  |  87 lines

  1. #ifndef DCOMPLEXFFT_H
  2. #define DCOMPLEXFFT_H
  3. #pragma once
  4.  
  5. /*
  6.  *    Double Precision Complex FFT server
  7.  *
  8.  *    Copyright (C) 1988, 1989.
  9.  *
  10.  *    Dr. Thomas Keffer
  11.  *    Rogue Wave Associates
  12.  *    P.O. Box 85341
  13.  *    Seattle WA 98145-1341
  14.  *
  15.  *    Permission to use, copy, modify, and distribute this
  16.  *    software and its documentation for any purpose and
  17.  *    without fee is hereby granted, provided that the
  18.  *    above copyright notice appear in all copies and that
  19.  *    both that copyright notice and this permission notice
  20.  *    appear in supporting documentation.
  21.  *    
  22.  *    This software is provided "as is" without any
  23.  *    expressed or implied warranty.
  24.  *
  25.  *
  26.  *    @(#)DComplexFFT.h    2.1    8/18/89
  27.  */
  28.  
  29. #include "DComplexVec.h"
  30.      
  31. /*
  32.  
  33. This class does complex fourier transforms of a series of a specified
  34. length.  It can serve as the nucleus by which to do a wide variety of
  35. transforms and, indeed, is inherited by several other servers.  The
  36. NCAR FFT routines are used to perform the actual calculations.  This
  37. can easily be replaced by specialized hardware or another algorithm.
  38.  
  39. The DFT calculated is:
  40.  
  41.                N-1
  42.         A(n) = sum X(j) exp(-2 * pi * n * j * I / N);      n=0,...,N-1
  43.                j=0
  44.  
  45. The IDFT calculated is similar:
  46.  
  47.                N-1
  48.         X(j) = sum A(n) exp( 2 * pi * n * j * I / N);      j=0,...,N-1
  49.                n=0
  50.  
  51. where A and X are complex.  Note that the sum is NOT normalized: a
  52. call to fourier(), followed by a call to ifourier() will result in the
  53. original series multiplied by N.
  54.  
  55. It precalculates the weights necessary to do the transform.  If it is
  56. handed a series of a different length, it will reconfigure, an
  57. expensive calculation.  Hence, it is most efficient to call it
  58. repeatedly for series of the same length.  Construct several servers
  59. to handle a variety of lengths.
  60.  
  61. */
  62.  
  63. class DComplexFFTServer {
  64.   unsigned        server_N;
  65. protected:
  66.   DoubleVec        the_weights;
  67. public:
  68.   DComplexFFTServer();
  69.   DComplexFFTServer(unsigned oforder);
  70.   DComplexFFTServer(const DComplexFFTServer&);
  71.  
  72.   void            operator=(const DComplexFFTServer&);
  73.  
  74.   unsigned        order()    {return server_N;}
  75.   void            setOrder(unsigned); // Set new N
  76.  
  77.   /***********  TRANSFORMS ***********/
  78.   // Returns DFT of a complex sequence:
  79.   DComplexVec        fourier(const DComplexVec&);
  80.   // Returns IDFT of a complex sequence:
  81.   DComplexVec        ifourier(const DComplexVec&);
  82. };
  83.  
  84. // Other useful functions:
  85.   double        spectralVariance(const DComplexVec&);
  86. #endif
  87.